import React from 'react';

import axios from 'axios';
import {Link} from 'react-router';

class Asign extends React.Component{
    constructor(props){
        super(props);
        this.state={
            list:[],
            
        }
        this.getData=this.getData.bind(this);
    }

    componentWillMount(){ //渲染之前请求数据
       
            this.getData();
       
        
    }


    getData(){
        //请求数据

        var that=this;

        axios.get('http://www.phonegap100.com/appapi.php?a=getPortalList&catid=20&page=1')
        .then(function (response) {
           

            that.setState({

                list:response.data.result,
                
                
            })
            that.state.list.map(function(value){
                sessionStorage.setItem(value.aid,value.title);
            })
          


        })
        .catch(function (error) {
            console.log(error);
        });

    }
    render(){
        return(
            <div className="lis">
               
                <ul>
                    {this.state.list.map(function(value,key){
                        return <li key={key}><Link to={{pathname:"detail/"+value.aid}}>{value.title}</Link></li>
                    })}
                </ul>
                 <div className="esrc-footer">
                 Copyright © 2015 
                 <a href="http://www.ele.me">Ele.me</a>
                 . All Rights Reserved 
            </div>
            </div>
        )
    }
}


export default Asign;